import moment from 'moment'
// 格式化时间
export const format = time => {
  return moment(time).format('YYYY-MM-DD')
}
// 转换订单状态
export const shiftToCN = value => {
  switch (value) {
    case 0:
      value = '创建'
      break
    case 1:
      value = '支付完成'
      break
    case 2:
      value = '出货成功'
      break
    case 3:
      value = '出货失败'
      break
    default:
      break
  }
  return value
}
// 处理工单列表
export const dealList = list => {
  return list.map(item => {
    item.createType = item.createType ? '手动' : '自动'
    item.createTime = item.createTime.replace(/T/, ' ')
    item.updateTime = item.updateTime.replace(/T/, ' ')
    if (item.payStatus) {
      item.payStatus = shiftToCN(item.payStatus)
    }
    return item
  })
}
// 设置页码
export const setPagination = (obj, data) => {
  obj.totalCount = data.totalCount
  obj.totalPage = data.totalPage
}
